/*
 * PKL 51 GUNUNG KIDUL
 * Subseksie DATA ENTRY + CAPI
 */
package pkl51.model;

import java.io.Serializable;
import pkl51.entity.Blok6a;
import pkl51.error.EntityException;
import pkl51.model.event.Blok6AListener;
import pkl51.service.Blok6aDao;
import pkl51.service.impl.Blok6aDaoImpl;

/**
 *
 * @author FITRI ANDRI ASTUTI
 */
public class Blok6AModel implements Serializable{
    private static Blok6AModel instance;
    private static final long serialVersionUID = 2982611916355638708L;
    private String NKS;
    private String B6AR1a;
    private String B6AR1b;
    private String B6AR2a;
    private String B6AR2b;
    private String B6AR2c;
    private String B6AR2d;
    private String B6AR2e;
    private String B6AR2f;
    private String B6AR2g;
    private String B6AR2h;
    private String B6AR2i;
    private String B6AR2j;
    private String B6AR2k;
    private String B6AR2l;
    private String B6AR2m;
    private String B6AR2n;
    private String B6AR2o;
    private Blok6AListener listener;
    
    public void setForDB(String B6AR1a, String B6AR1b, String B6AR2a, String B6AR2b, String B6AR2c, String B6AR2d, String B6AR2e, String B6AR2f, String B6AR2g, String B6AR2h, String B6AR2i, String B6AR2j, String B6AR2k, String B6AR2l, String B6AR2m, String B6AR2n, String B6AR2o) {
        this.B6AR1a = B6AR1a;
        this.B6AR1b = B6AR1b;
        this.B6AR2a = B6AR2a;
        this.B6AR2b = B6AR2b;
        this.B6AR2c = B6AR2c;
        this.B6AR2d = B6AR2d;
        this.B6AR2e = B6AR2e;
        this.B6AR2f = B6AR2f;
        this.B6AR2g = B6AR2g;
        this.B6AR2h = B6AR2h;
        this.B6AR2i = B6AR2i;
        this.B6AR2j = B6AR2j;
        this.B6AR2k = B6AR2k;
        this.B6AR2l = B6AR2l;
        this.B6AR2m = B6AR2m;
        this.B6AR2n = B6AR2n;
        this.B6AR2o = B6AR2o;
    }

    private Blok6AModel() {
        this.NKS = Blok123Model.getInstance().getNKS();
    }

    public static Blok6AModel getInstance(){
        if(instance==null){
            instance = new Blok6AModel();
        }
        return instance;
    }
    
    protected void fireOnChange(Blok6AModel model) {
        if (listener != null) {
            listener.onChange(this);
        }
    }
    
    public Blok6AListener getListener() {
        return listener;
    }
    
    public String getB6AR1a() {
        return B6AR1a;
    }

    public String getB6AR1b() {
        return B6AR1b;
    }

    public String getB6AR2a() {
        return B6AR2a;
    }

    public String getB6AR2b() {
        return B6AR2b;
    }

    public String getB6AR2c() {
        return B6AR2c;
    }

    public String getB6AR2d() {
        return B6AR2d;
    }

    public String getB6AR2e() {
        return B6AR2e;
    }

    public String getB6AR2f() {
        return B6AR2f;
    }

    public String getB6AR2g() {
        return B6AR2g;
    }

    public String getB6AR2h() {
        return B6AR2h;
    }

    public String getB6AR2i() {
        return B6AR2i;
    }

    public String getB6AR2j() {
        return B6AR2j;
    }

    public String getB6AR2k() {
        return B6AR2k;
    }

    public String getB6AR2l() {
        return B6AR2l;
    }

    public String getB6AR2m() {
        return B6AR2m;
    }

    public String getB6AR2n() {
        return B6AR2n;
    }

    public String getB6AR2o() {
        return B6AR2o;
    }

    public String getNKS() {
        return NKS;
    }

    public void setB6AR1a(String B6AR1a) {
        this.B6AR1a = B6AR1a;
        fireOnChange(this);
    }

    public void setB6AR1b(String B6AR1b) {
        this.B6AR1b = B6AR1b;
        fireOnChange(this);
    }

    public void setB6AR2a(String B6AR2a) {
        this.B6AR2a = B6AR2a;
        fireOnChange(this);
    }

    public void setB6AR2b(String B6AR2b) {
        this.B6AR2b = B6AR2b;
        fireOnChange(this);
    }

    public void setB6AR2c(String B6AR2c) {
        this.B6AR2c = B6AR2c;
        fireOnChange(this);
    }

    public void setB6AR2d(String B6AR2d) {
        this.B6AR2d = B6AR2d;
        fireOnChange(this);
    }

    public void setB6AR2e(String B6AR2e) {
        this.B6AR2e = B6AR2e;
        fireOnChange(this);
    }

    public void setB6AR2f(String B6AR2f) {
        this.B6AR2f = B6AR2f;
        fireOnChange(this);
    }

    public void setB6AR2g(String B6AR2g) {
        this.B6AR2g = B6AR2g;
        fireOnChange(this);
    }

    public void setB6AR2h(String B6AR2h) {
        this.B6AR2h = B6AR2h;
        fireOnChange(this);
    }

    public void setB6AR2i(String B6AR2i) {
        this.B6AR2i = B6AR2i;
        fireOnChange(this);
    }

    public void setB6AR2j(String B6AR2j) {
        this.B6AR2j = B6AR2j;
        fireOnChange(this);
    }

    public void setB6AR2k(String B6AR2k) {
        this.B6AR2k = B6AR2k;
        fireOnChange(this);
    }

    public void setB6AR2l(String B6AR2l) {
        this.B6AR2l = B6AR2l;
        fireOnChange(this);
    }

    public void setB6AR2m(String B6AR2m) {
        this.B6AR2m = B6AR2m;
        fireOnChange(this);
    }

    public void setB6AR2n(String B6AR2n) {
        this.B6AR2n = B6AR2n;
        fireOnChange(this);
    }

    public void setB6AR2o(String B6AR2o) {
        this.B6AR2o = B6AR2o;
        fireOnChange(this);
    }

    public void setNKS(String NKS) {
        this.NKS = NKS;
        fireOnChange(this);
    }
    
    public void setListener(Blok6AListener listener) {
        this.listener = listener;
    }
    
    public void insertBlok6a() throws EntityException{
        this.NKS = Blok123Model.getInstance().getNKS();
        Blok6aDao dao = new Blok6aDaoImpl();
        Blok6a blok6a= new Blok6a();
        blok6a.setNKS(NKS);
        blok6a.setB6AR1a(B6AR1a);
        blok6a.setB6AR1b(B6AR1b);
        blok6a.setB6AR2a(Integer.valueOf(B6AR2a));
        blok6a.setB6AR2b(Integer.valueOf(B6AR2b));
        blok6a.setB6AR2c(Integer.valueOf(B6AR2c));
        blok6a.setB6AR2d(Integer.valueOf(B6AR2d));
        blok6a.setB6AR2e(Integer.valueOf(B6AR2e));
        blok6a.setB6AR2f(Integer.valueOf(B6AR2f));
        blok6a.setB6AR2g(Integer.valueOf(B6AR2g));
        blok6a.setB6AR2h(Integer.valueOf(B6AR2h));
        blok6a.setB6AR2i(Integer.valueOf(B6AR2i));
        blok6a.setB6AR2j(Integer.valueOf(B6AR2j));
        blok6a.setB6AR2k(Integer.valueOf(B6AR2k));
        blok6a.setB6AR2l(Integer.valueOf(B6AR2l));
        blok6a.setB6AR2m(Integer.valueOf(B6AR2m));
        blok6a.setB6AR2n(Integer.valueOf(B6AR2n));
        blok6a.setB6AR2o(Integer.valueOf(B6AR2o));        

        dao.insertBlok6a(blok6a);
    }
    public void updateBlok6a() throws EntityException{
        this.NKS = Blok123Model.getInstance().getNKS();
        Blok6aDao dao = new Blok6aDaoImpl();
        Blok6a blok6a= new Blok6a();
        
        blok6a.setNKS(NKS);
        blok6a.setB6AR1a(B6AR1a);
        blok6a.setB6AR1b(B6AR1b);
        blok6a.setB6AR2a(Integer.valueOf(B6AR2a));
        blok6a.setB6AR2b(Integer.valueOf(B6AR2b));
        blok6a.setB6AR2c(Integer.valueOf(B6AR2c));
        blok6a.setB6AR2d(Integer.valueOf(B6AR2d));
        blok6a.setB6AR2e(Integer.valueOf(B6AR2e));
        blok6a.setB6AR2f(Integer.valueOf(B6AR2f));
        blok6a.setB6AR2g(Integer.valueOf(B6AR2g));
        blok6a.setB6AR2h(Integer.valueOf(B6AR2h));
        blok6a.setB6AR2i(Integer.valueOf(B6AR2i));
        blok6a.setB6AR2j(Integer.valueOf(B6AR2j));
        blok6a.setB6AR2k(Integer.valueOf(B6AR2k));
        blok6a.setB6AR2l(Integer.valueOf(B6AR2l));
        blok6a.setB6AR2m(Integer.valueOf(B6AR2m));
        blok6a.setB6AR2n(Integer.valueOf(B6AR2n));
        blok6a.setB6AR2o(Integer.valueOf(B6AR2o));

        dao.updateBlok6a(blok6a);
    }
    
    public void getBlok6a() throws EntityException{
        this.NKS = Blok123Model.getInstance().getNKS();
        Blok6aDao dao = new Blok6aDaoImpl();
        Blok6a blok6a = dao.getBlok6aByNKS(NKS);
        setNKS(blok6a.getNKS());
        setB6AR1a(blok6a.getB6AR1a());
        setB6AR1b(blok6a.getB6AR1b());
        setB6AR2a(String.valueOf(blok6a.getB6AR2a()));
        setB6AR2b(String.valueOf(blok6a.getB6AR2b()));
        setB6AR2c(String.valueOf(blok6a.getB6AR2c()));
        setB6AR2d(String.valueOf(blok6a.getB6AR2d()));
        setB6AR2e(String.valueOf(blok6a.getB6AR2e()));
        setB6AR2f(String.valueOf(blok6a.getB6AR2f()));
        setB6AR2g(String.valueOf(blok6a.getB6AR2g()));
        setB6AR2h(String.valueOf(blok6a.getB6AR2h()));
        setB6AR2i(String.valueOf(blok6a.getB6AR2i()));
        setB6AR2j(String.valueOf(blok6a.getB6AR2j()));
        setB6AR2k(String.valueOf(blok6a.getB6AR2k()));
        setB6AR2l(String.valueOf(blok6a.getB6AR2l()));
        setB6AR2m(String.valueOf(blok6a.getB6AR2m()));
        setB6AR2n(String.valueOf(blok6a.getB6AR2n()));
        setB6AR2o(String.valueOf(blok6a.getB6AR2o()));
        
    }
    
    public void resetModel(){
        setNKS("");
        setB6AR1a("");
        setB6AR1b("");
        setB6AR2a("");
        setB6AR2b("");
        setB6AR2c("");
        setB6AR2d("");
        setB6AR2e("");
        setB6AR2f("");
        setB6AR2g("");
        setB6AR2h("");
        setB6AR2i("");
        setB6AR2j("");
        setB6AR2k("");
        setB6AR2l("");
        setB6AR2m("");
        setB6AR2n("");
        setB6AR2o("");
    }
}
